package cn.com.enums;

import cn.com.bean.ResultResponse;
import cn.com.utils.HttpClientUtil;
import lombok.Getter;

import java.util.Map;


/**
 * https方法
 *
 * @author LiuGuodong
 * @date 2023/10/27
 */
@Getter
public enum HttpsMethod {
    POST(HttpClientUtil::post),
    PUT(HttpClientUtil::put),
    DELETE(HttpClientUtil::delete),
    GET(HttpClientUtil::get);

    private final HttpsRequest method;

    HttpsMethod(HttpsRequest method) {
        this.method = method;
    }

    @FunctionalInterface
    public interface HttpsRequest {
        /**
         * 执行
         *
         * @param url     url
         * @param headers 请求头
         * @param body    请求参数
         * @return {@link }
         * @throws Exception 异常
         */
        ResultResponse execution(String url, Map<String, String> headers, String body) throws Exception;
    }

}
